<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{:session('cp.cpsysname')}--系统管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="runoob">
    <link rel="stylesheet" href="__STATIC_URL__/static/css/bootstrapSwitch.css">
    <link rel="stylesheet" href="__STATIC_URL__/static/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/chioce.css">
    <link href="https://cdn.bootcss.com/bootstrap-select/2.0.0-beta1/css/bootstrap-select.css" rel="stylesheet">
    <script src="__STATIC_URL__/static/js/jquery-2.1.4.min.js"></script>
    <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="__STATIC_URL__/static/js/bootstrapSwitch.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap-select/2.0.0-beta1/js/bootstrap-select.js"></script>
</head>
<body>
{include file='public/header'/}
<!------------------导航-------------------------->
<section>
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ul class="breadcrumb">
                <li>当前位置是&nbsp;:</li>
                <li><a href="javascript:history.back();">员工管理</a></li>
                <li class="active" style="color: #02b87f;"> 添加用户</li>
            </ul>
        </div>
        <div class="panel mgr15 mgl15">
            <div class="panel-heading addCharts" style="background:#ededed;">
                添加用户
            </div>
            <div class="panel-body">
                <form class="form-horizontal adminex-form" action='' method="post" id="sysuser" enctype="multipart/form-data">
                    <div class="form-group" id="ferror5">
                        <label class="col-sm-2 control-label">员工角色：</label>
                        <div class="col-sm-10">
                            <select class="form-control" name='level' id='level' style="width:70%;">
                                <option value=''>请选择角色</option>
                                {volist name="dice" id="level"}
                                    <option value='{$level.value}'>{$level.text}</option>
                                {/volist}
                            </select>
                            <div id="error5" class="error"></div>
                        </div>
                    </div>

                    <div class="form-group" id="ferror6" >
                        <label class="col-sm-2 control-label">工号：</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id='gonghao' name='gonghao' style="width:70%;">
                            <div id="error6" class="error"></div>
                        </div>
                    </div>
                    <div class="form-group" id="ferror1" >
                        <label class="col-sm-2 control-label">姓名：</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id='xingming' name='xingming' style="width:70%;">
                            <div id="error1" class="error"></div>
                        </div>
                    </div>
                    <div class="form-group" id="ferror3" >
                        <label class="col-sm-2 control-label">手机号：</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" oninput="this.value=this.value.replace(/\D/g,'')" id='tel' name='tel' style="width:70%;" autocomplete="off" disableautocomplete>
                            <div id="error3" class="error"></div>
                        </div>
                    </div>
                    <div class="form-group" id="ferror7" >
                        <label class="col-sm-2 control-label">账号：</label>
                        <div class="col-sm-10">
                            <input type="text" style="background:#fff;width:70%;" readonly onfocus="this.removeAttribute('readonly');" class="form-control" id='username' name='username' autocomplete="off" disableautocomplete>
                            <div id="error7" class="error"></div>
                        </div>
                    </div>
                    <div class="form-group" id="ferror2">
                        <label class="col-sm-2 control-label">密码：</label>
                        <div class="col-sm-10">
                            <input type="password" style="background:#fff;width:70%;" readonly onfocus="this.removeAttribute('readonly');"  id='password' name='password' class="form-control" autocomplete="off" disableautocomplete >
                            <div id="error2" class="error"></div>
                        </div>
                    </div>
                    <div class="form-group" id="ferror4">
                        <label class="col-sm-2 control-label">所属门店：</label>
                        <div class="col-sm-10">
                            {volist name="mach" id="mach"}
                            <span class="checkbox ng-scope checkbox-inline">
                                <input name="mid[]" value="{$mach.id}" type="checkbox" class="checkmid">
                                <label class="ng-binding">{$mach.merchant}</label>
                            </span>
                            {/volist}
                            <div id="error4" class="error"></div>
                        </div>
                    </div>
                    <div class="form-group" style="height: 25px;">
                        <label class="col-sm-2 control-label">是否支持退款：</label>
                        <div class="col-sm-10">
                            <div class="switch switch-small is_kt" data-animated="true">
                                <input type="checkbox" id="is_kt" name="is_kt" value="0"/>
                            </div>
                        </div>
                    </div>

                    <div style="text-align: center">

                        <button type="button" onclick="addform()" class="btn btn-primary">添加用户</button>
                    </div>
                </form>
            </div>
        </div>
        {include file='public/footer'/}

    </div>
</section>
<script>
    function addform() {
        $('#ferror1,#ferror3,#ferror5,ferror7,ferror2').removeClass('has-error');
        $(".error").text("");
        var level = $("#level").val();
        var username = $('#username').val();
        var password = $('#password').val();
        var tel = $("#tel").val();
        var qx = $('#qx').val();
        var xingming = $("#xingming").val();
        var mid = $("#mid").val();
        if(level==""){
            $('#ferror5').addClass('has-error');
            $('#error5').text('请选择员工角色');
            $('#level').focus();
            return;
        }

        if(xingming==""){
            $('#ferror1').addClass('has-error');
            $('#error1').text('姓名不能为空');
            $('#xingming').focus();
            return;
        }
        if(tel==""){
            $('#ferror3').addClass('has-error');
            $('#error3').text('手机号不能为空');
            $('#tel').focus();
            return;
        }
        if (username === '') {
            $('#ferror7').addClass('has-error');
            $('#error7').text('用户名不能为空');
            $('#username').focus();
            return;

        }
        if (password === '') {
            $('#ferror2').addClass('has-error');
            $('#error2').text('用户密码不能为空');
            $('#password').focus();
            return;

        }
        if (mid === '') {
            $('#ferror4').addClass('has-error');
            $('#error4').text('请选择所属门店');
            $('#mid').focus();
            return;

        }
        $('#sysuser').submit();

    }
    function showqx(va) {

        switch (va.value) {
            case '0' :
                $('#levelst').hide();
                $('#machlist').hide();
                break;
            case '1':
                $('#levelst').show();
                $('#machlist').hide();
                break;
            case '2' :
                $('#machlist').hide()
                $('#levelst').hide();
                break;
            case '3' :
                $('#machlist').show();
                $('#levelst').hide();
                break;
            case '4':
                $('#machlist').show();
                $('#levelst').hide();
                break;
            default:
                alert(555);
        }
    }
    $(function(){
        $('.is_kt').on('switch-change',function (e, data) {
            var $el = $(data.el),value = data.value;
            if(value==true){
                $("#is_kt").val(1);
            }else if(value==false){
                $("#is_kt").val(0);
            }

        });
    })
</script>
</body>
</html>
